package cn.kgc.vue.controller;

import cn.kgc.vue.common.ResponseResult;
import cn.kgc.vue.common.ResponseStatus;
import cn.kgc.vue.entity.Schedule;
import cn.kgc.vue.form.ScheduleLsitForm;
import cn.kgc.vue.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/***
 *@title ScheduleController
 *@author 韩旭
 *@version 1.0.0
 *@create 2023/8/20 18:36
 **/
@RestController
@RequestMapping("schedule")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    //模糊搜索和分页查询
    @GetMapping("getlist")
    public ResponseResult getlist(ScheduleLsitForm scheduleLsitForm) {
        return scheduleService.getlist(scheduleLsitForm);
    }

    @PostMapping("addorupdate")
    public ResponseResult addorupdate(@RequestBody Schedule schedule) {
        ResponseResult responseResult = new ResponseResult();
        scheduleService.saveOrUpdate(schedule);
        responseResult.success(ResponseStatus.SUCCESS);
        return responseResult;
    }

    @DeleteMapping("delete")
    public ResponseResult delete(@RequestBody List<Integer> ids) {
        ResponseResult responseResult = new ResponseResult();
        scheduleService.removeBatchByIds(ids);
        responseResult.success(ResponseStatus.DELETE_SUCCESS);
        return responseResult;
    }

}
